package com.kedacom.freedomLabel.model.db.dao;

import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;

import com.kedacom.freedomLabel.model.bean.Config;

import java.util.List;

/**
 * created by: tangqi
 * on: 2019/11/24
 * description:
 **/
@Dao
public interface ConfigDao extends IDao<Config> {

    @Override
    @Query("SELECT COUNT(0) FROM Config")
    int count();

    @Override
    @Update
    void update(Config config);

    @Override
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    long save(Config Config);

    @Override
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    long[] save(List<Config> Configs);

    @Override
    @Query("SELECT * FROM Config")
    List<Config> get();

    @Override
    @Query("SELECT * FROM Config WHERE configKey =:configKey")
    List<Config> get(String configKey);

    @Override
    @Query("SELECT * FROM Config WHERE configKey =:configKey OR configKey =:param2")
    List<Config> get(String configKey, String param2);

    @Override
    @Delete
    void delete(Config Config);

    @Override
    @Query("DELETE FROM Config")
    void delete();

    @Override
    @Query("DELETE FROM CONFIG WHERE configKey =:key")
    void delete(String key);
}
